package com.zyf.EasyNet.model;

/**
 * @first_author zyflzz
 * @gmt_created 2022/6/3
 * @gmt_modified 2022/6/3
 */

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;

/**
 * 返回结果数据模型
 *
 * @param <D> 数据类型
 */
public class Result<D> implements Serializable {

    /**
     * 表示是否操作成功
     */
    @JsonProperty("isSuccess")
    private boolean success = false;

    /**
     * 返回代码
     */
    private int code;
    // 返回消息
    private String message;

    /**
     * 返回数据
     */
    private D data;

    public static <T> Result<T> create() {
        return new Result<T>();
    }

    public boolean isSuccess() {
        return success;
    }

    public Result setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public int getCode() {
        return code;
    }

    public Result<D> setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public Result<D> setMessage(String message) {
        this.message = message;
        return this;
    }

    public D getData() {
        return data;
    }

    public Result<D> setData(D data) {
        this.data = data;
        return this;
    }
}

